minetest.register_node("lunocarpets:rebirth", {
	description = "Carpete Respawn",
	drawtype = "nodebox",
	paramtype = "light", --Não sei pq, mas o bloco não aceita a luz se nao tiver esta propriedade
	paramtype2 = "facedir",
	--sunlight_propagates = true,
	--light_source = LIGHT_MAX, --Este tapete brilha no escuro pq é mágico.
	node_box = {
		type = "fixed",
		fixed = { {-.5,-.5,-.5,    .5,-.47,.5}	}
	},
	selection_box = {
		type = "fixed",
		fixed = { {-.5,-.5,-.5,    .5,-.47,.5}	}
	},
	tiles = {
		"tapete_96x96.png", --acima
		"tapete_96x96.png^[transformfx",  --abaixo
		"tapete_lado.png" --lados
	},
	groups = {vessel=1,dig_immediate=3,attached_node=1},
	--sounds = default.node_sound_wood_defaults(),
	after_place_node = function(pos, placer, itemstack)
		local owner = placer:get_player_name()
		local valor = lunomods.getCharValue(owner, "posRespawn")
		if valor~=nil and valor~="" then
			posOld = minetest.string_to_pos(valor)
			minetest.remove_node(posOld)
		end
		local meta = minetest.env:get_meta(pos)
		meta:set_string("infotext", "Carpete de renascimento de '"..owner.."'.")
		meta:set_string("owner",owner)
		lunomods.setCharValue(owner, "posRespawn",minetest.pos_to_string(pos))
	end,
	can_dig = function(pos, player)
		local myDiger = player:get_player_name()
		local myOwner = minetest.env:get_meta(pos):get_string("owner")
		if myDiger~=nil and myOwner~=nil and myDiger == myOwner then
			lunomods.setCharValue(myDiger, "posRespawn", nil)
		end
		return myOwner==nil or myOwner=="" or myDiger == myOwner
	end,
})

minetest.register_craft({
	output = 'lunocarpets:rebirth',
	recipe = {
		{"lunorecipes:magicdust"},
		{"lunocarpets:wellcome"},
		{"bones:bones"}
	}
})

minetest.register_alias("rebirthcarpet"		,"lunocarpets:rebirth")
minetest.register_alias("carpetederenascimento"	,"lunocarpets:rebirth")
minetest.register_alias("tapetederenascimento"	,"lunocarpets:rebirth")
